Code Page

library(tidyverse) 
happy2023=read.csv("happiness2023.csv")
happy2024=read.csv("happiness2024.csv") 
happy2025=read.csv("happiness2025.csv") 

Hap25 = ggplot(tail(arrange(happy2025,desc(WorldHappinessRank_2025)),10),aes(x=country, y=WorldHappinessScore_2025, fill = country))+
  geom_bar(stat="identity")+
  labs(x="Country Name",
       y="Happiness Score",
       title="Top 10 Happiest Countries in 2025")+
  coord_flip()+
  theme(legend.position="none")

This portion of the code is for the 2024 top 10 countries, I decided to omit it from the redesign page as it would be repetitive and not useful for my presentation/report.

Hap24 = ggplot(tail(arrange(happy2024,desc(WorldHappinessRank_2024)),10), aes(x=country, y=WorldHappinessScore_2024, fill= country))+
  geom_bar(stat="identity")+
  labs(x="Country Name",
       y="Happiness Score",
       title="Top 10 Happiest Countries in 2024")+
  coord_flip()+
  theme(legend.position="none")  
Hap23 = ggplot(tail(arrange(happy2023,desc(WorldHappinessRank_2023)), 10), aes(x=country, y=WorldHappinessScore_2023, fill= country))+
  geom_bar(stat="identity")+
  labs(x="Country Name",
       y="Happiness Score",
       title="Top 10 Happiest Countries in 2023")+
  coord_flip()+
  theme(legend.position="none")  
HappinessDiff2025 = happy2025 %>%
  inner_join(happy2023, by = "country") %>%
  mutate(Difference = WorldHappinessScore_2025 - WorldHappinessScore_2023) 

HappinessDiff2025= arrange(HappinessDiff2025, desc(Difference))

HapDiff25 = ggplot(head(HappinessDiff2025,10), aes(x=country, y=Difference, fill= country))+
  geom_bar(stat="identity")+
  labs(x="Country Name",
       y="Increase in Happiness Score",
       title="Top 10 Countries with a Change in Happiness between 2023 and 2025")+   coord_flip()+
  theme(legend.position="none")
world_tbl <- map_data("world") %>% as_tibble()
world_tbl = world_tbl %>%
  left_join(HappinessDiff2025, by = c("region"= "country"))
#world_tbl =  world_tbl %>% filter(!is.na(world_tbl$WorldHappinessScore_2025))

world_base <- world_tbl %>%
  ggplot(aes(long, lat,  map_id = region)) +
  geom_map( aes(map_id= region),
            map= world_tbl)+
  geom_polygon(aes(fill = Difference), color = "black")+
  coord_map(xlim=c(-180,180))

world_base = world_base +
  scale_fill_gradient(name = "Change in Happiness Score", low = "yellow",                                    high =  "darkgreen", na.value = "grey50")